#pragma once

// Disable warnings about invalid XML
#pragma warning(disable:4635)
#include <Awesomium/WebView.h>
#pragma warning(default:4635)

using namespace System;
using namespace System::Collections::Generic;
using namespace System::Collections::ObjectModel;
using namespace System::Drawing;
using namespace System::Windows::Forms;

namespace AwesomiumDotNet
{
	ref class JSValue;
	ref class FutureJSValue;
	ref class RenderBuffer;
	ref class ResourceInterceptor;
	ref class WebCore;
	ref class WebView;
	ref class WebKeyboardEvent;

	/// <summary>
	/// An enumeration of all the possible web cursors. Used with 
	/// WebView.OnChangeCursor.
	/// </summary>
	public enum class CursorType
	{
		Pointer,
		Cross,
		Hand,
		IBeam,
		Wait,
		Help,
		EastResize,
		NorthResize,
		NorthEastResize,
		NorthWestResize,
		SouthResize,
		SouthEastResize,
		SouthWestResize,
		WestResize,
		NorthSouthResize,
		EastWestResize,
		NorthEastSouthWestResize,
		NorthWestSouthEastResize,
		ColumnResize,
		RowResize,
		MiddlePanning,
		EastPanning,
		NorthPanning,
		NorthEastPanning,
		NorthWestPanning,
		SouthPanning,
		SouthEastPanning,
		SouthWestPanning,
		WestPanning,
		Move,
		VerticalText,
		Cell,
		ContextMenu,
		Alias,
		Progress,
		NoDrop,
		Copy,
		None,
		NotAllowed,
		ZoomIn,
		ZoomOut,
		Custom
	};

	/// <summary>
	/// Mouse button enumerations,
	/// used with WebView.InjectMouseDown and WebView.InjectMouseUp
	/// </summary>
	public enum class MouseButton
	{
		Left, Middle, Right
	};

	/// <summary>
	/// URL Filtering mode enumerations, used by WebView.SetUrlFilteringMode
	/// </summary>
	public enum class UrlFilteringMode
	{
		/// <summary>
		/// All resource requests and page navigations are ALLOWED 
		/// except those that match the URL filters specified.
		/// </summary>
		Blacklist,

		/// <summary>
		/// All resource requests and page navigations are DENIED 
		/// except those that match the URL filters specified.
		/// </summary>
		Whitelist,

		/// <summary>
		/// No filtering
		/// </summary>
		None
	};

	public ref class BeginLoadingEventArgs : System::EventArgs
	{
	public:
		/// <summary>The WebView that fired the event.</summary>
		property WebView^ WebView;
		/// <summary>The URL of the frame that is being loaded.</summary>
		property String^ Url;
		/// <summary>The name of the frame that this event originated from.</summary>
		property String^ FrameName;
		/// <summary>The HTTP status code returned by the server.</summary>
		property int StatusCode;
		/// <summary>The mime-type of the content that is being loaded.</summary>
		property String^ MimeType;

		BeginLoadingEventArgs(AwesomiumDotNet::WebView^ webView, String^ url, String^ frameName, int statusCode, String^ mimeType);
	};

	public ref class BeginNavigationEventArgs : System::EventArgs
	{
	public:
		/// <summary>The WebView that fired the event.</summary>
		property WebView^ WebView;
		/// <summary>The URL that is being navigated to.</summary>
		property String^ Url;
		/// <summary>The name of the frame that this event originated from.</summary>
		property String^ FrameName;

		BeginNavigationEventArgs(AwesomiumDotNet::WebView^ webView, String^ url, String^ frameName);
	};

	public ref class CallbackEventArgs : System::EventArgs
	{
	private:
		Collection<JSValue^>^ _args;

	public:
		/// <summary>The WebView that fired the event.</summary>
		property WebView^ WebView;
		/// <summary>The name of the JavaScript Object that contains the invoked callback.</summary>
		property String^ ObjectName;
		/// <summary>The name of the callback that was invoked (must have been previously bound via WebView.SetObjectCallback).</summary>
		property String^ CallbackName;
		/// <summary>The arguments passed to the callback.</summary>
		property Collection<JSValue^>^ Args
		{
			Collection<JSValue^>^ get() { return _args; }
		}

		CallbackEventArgs(AwesomiumDotNet::WebView^ webView, String^ objectName, String^ callbackName, Collection<JSValue^>^ args);
	};

	public ref class ChangeCursorEventArgs : System::EventArgs
	{
	public:
		/// <summary>The WebView that fired the event.</summary>
		property WebView^ WebView;
		/// <summary>The cursor type.</summary>
		property CursorType CursorType;
		/// <summary>The cursor object.</summary>
		property Windows::Forms::Cursor^ Cursor
		{
			Windows::Forms::Cursor^ get();
		}

		ChangeCursorEventArgs(AwesomiumDotNet::WebView^ webView, AwesomiumDotNet::CursorType cursorType);
	};

	public ref class ChangeKeyboardFocusEventArgs : System::EventArgs
	{
	public:
		/// <summary>The WebView that fired the event.</summary>
		property WebView^ WebView;
		/// <summary>Whether or not the keyboard is currently focused.</summary>
		property bool IsFocused;

		ChangeKeyboardFocusEventArgs(AwesomiumDotNet::WebView^ webView, bool isFocused);
	};

	public ref class ChangeTargetUrlEventArgs : System::EventArgs
	{
	public:
		/// <summary>The WebView that fired the event.</summary>
		property WebView^ WebView;
		/// <summary>The updated target URL (or empty if the target URL is cleared).</summary>
		property String^ Url;

		ChangeTargetUrlEventArgs(AwesomiumDotNet::WebView^ webView, String^ url);
	};

	public ref class ChangeTooltipEventArgs : System::EventArgs
	{
	public:
		/// <summary>The WebView that fired the event.</summary>
		property WebView^ WebView;
		/// <summary>The tooltip text (or, is an empty string when the tooltip should disappear).</summary>
		property String^ Tooltip;

		ChangeTooltipEventArgs(AwesomiumDotNet::WebView^ webView, String^ tooltip);
	};

	public ref class DomReadyEventArgs : System::EventArgs
	{
	public:
		/// <summary>The WebView that fired the event.</summary>
		property WebView^ WebView;

		DomReadyEventArgs(AwesomiumDotNet::WebView^ webView);
	};

	public ref class FinishLoadingEventArgs : System::EventArgs
	{
	public:
		/// <summary>The WebView that fired the event.</summary>
		property WebView^ WebView;

		FinishLoadingEventArgs(AwesomiumDotNet::WebView^ webView);
	};

	public ref class GetPageContentsEventArgs : System::EventArgs
	{
	public:
		/// <summary>The WebView that fired the event.</summary>
		property WebView^ WebView;
		/// <summary>The URL of the page.</summary>
		property String^ Url;
		/// <summary>The contents of the page as plain text.</summary>
		property String^ Contents;

		GetPageContentsEventArgs(AwesomiumDotNet::WebView^ webView, String^ url, String^ contents);
	};

	public ref class OpenExternalLinkEventArgs : System::EventArgs
	{
	public:
		/// <summary>The WebView that fired the event.</summary>
		property WebView^ WebView;
		/// <summary>The URL of the external link.</summary>
		property String^ Url;
		/// <summary>The URL of the page that initiated the event. May be blank.</summary>
		property String^ Source;

		OpenExternalLinkEventArgs(AwesomiumDotNet::WebView^ webView, String^ url, String^ source);
	};

	public ref class PluginCrashedEventArgs : System::EventArgs
	{
	public:
		/// <summary>The WebView that fired the event.</summary>
		property WebView^ WebView;
		/// <summary>The name of the plugin that crashed.</summary>
		property String^ PluginName;

		PluginCrashedEventArgs(AwesomiumDotNet::WebView^ webView, String^ pluginName);
	};

	public ref class ReceiveTitleEventArgs : System::EventArgs
	{
	public:
		/// <summary>The WebView that fired the event.</summary>
		property WebView^ WebView;
		/// <summary>The page title.</summary>
		property String^ Title;
		/// <summary>The name of the frame that this event originated from.</summary>
		property String^ FrameName;

		ReceiveTitleEventArgs(AwesomiumDotNet::WebView^ webView, String^ title, String^ frameName);
	};

	public ref class RequestMoveEventArgs : System::EventArgs
	{
	public:
		/// <summary>The WebView that fired the event.</summary>
		property WebView^ WebView;

		/// <summary>The x-coordinate.</summary>
		property int X;
		/// <summary>The y-coordinate.</summary>
		property int Y;

		RequestMoveEventArgs(AwesomiumDotNet::WebView^ webView, int x, int y);
	};

	public ref class RequestDownloadEventArgs : System::EventArgs
	{
	public:
		/// <summary>The WebView that fired the event.</summary>
		property WebView^ WebView;
		/// <summary>The URL of the file requested to be downloaded.</summary>
		property String^ Url;

		RequestDownloadEventArgs(AwesomiumDotNet::WebView^ webView, String^ url);
	};

	public ref class WebViewCrashedEventArgs : System::EventArgs
	{
	public:
		/// <summary>The WebView that fired the event.</summary>
		property WebView^ WebView;

		WebViewCrashedEventArgs(AwesomiumDotNet::WebView^ webView);
	};

	public ref class GetScrollDataEventArgs : System::EventArgs
	{
	public:
		/// <summary>The WebView that fired the event.</summary>
		property WebView^ WebView;

		/// <summary>The width of the contents of the page
		/// (actual page width, NOT WebView width)</summary>
		property int ContentWidth;
		/// <summary>The height of the contents of the page
		/// (actual page height, NOT WebView height)</summary>
		property int ContentHeight;
		/// <summary>The preferred width of the page (usually the
		/// minimum width specified via CSS)</summary>
		property int PreferredWidth;
		/// <summary>The current scroll position (x value)</summary>
		property int ScrollX;
		/// <summary>The current scroll position (y value)</summary>
		property int ScrollY;

		GetScrollDataEventArgs(AwesomiumDotNet::WebView^ webView, int contentWidth, int contentHeight,
			int preferredWidth, int scrollX, int scrollY);
	};

	public ref class RequestFileChooserEventArgs : System::EventArgs
	{
	public:
		/// <summary>The WebView that fired the event.</summary>
		property WebView^ WebView;

		/// <summary>Whether or not the dialog should allow
		/// more than one file to be selected.</summary>
		property bool SelectMultipleFiles;
		/// <summary>The title to be displayed (if any).</summary>
		property String^ Title;
		/// <summary>The default file path the dialog should
		/// display (if any).</summary>
		property String^ DefaultPath;

		RequestFileChooserEventArgs(AwesomiumDotNet::WebView^ webView, bool selectMultipleFiles,
			String^ title, String^ defaultPath);
	};

	public ref class JavascriptConsoleMessageEventArgs : System::EventArgs
	{
	public:
		/// <summary>The WebView that fired the event.</summary>
		property WebView^ WebView;

		/// <summary>The console message.</summary>
		property String^ Message;
		/// <summary>The line number that the message occured on.</summary>
		property int LineNumber;
		/// <summary>The source (usually the filename) of the message.</summary>
		property String^ Source;

		JavascriptConsoleMessageEventArgs(AwesomiumDotNet::WebView^ webView, String^ message,
			int lineNumber, String^ source);
	};


	/// <summary>
	/// A WebView is similiar to a "tab" in a browser. You load pages into a 
	/// WebView, interact with it, and render it on-the-fly to a pixel buffer 
	/// (e.g., for use in an image/texture/etc). You create WebViews using the 
	/// WebCore (see WebCore.CreateWebView).
	/// </summary>
	public ref class WebView
	{
	private:
		Awesomium::WebView* webView;
		ResourceInterceptor^ resourceInterceptor;

	internal:
		bool markedDestroyed;

	public:
		/// <summary>This event is fired when a WebView begins to actually receive data from a server.</summary>
		event EventHandler<BeginLoadingEventArgs^>^ BeginLoading;

		/// <summary>This event is fired when a WebView begins navigating to a new URL.</summary>
		event EventHandler<BeginNavigationEventArgs^>^ BeginNavigation;

		/// <summary>This event is fired when a Client callback has been invoked via JavaScript from a page.</summary>
		event EventHandler<CallbackEventArgs^>^ Callback;

		/// <summary>This event is fired when a cursor has changed state.</summary>
		event EventHandler<ChangeCursorEventArgs^>^ ChangeCursor;

		/// <summary>This event is fired when keyboard focus has changed.</summary>
		event EventHandler<ChangeKeyboardFocusEventArgs^>^ ChangeKeyboardFocus;

		/// <summary>This event is fired when the target URL has changed. This is usually the result of
		/// hovering over a link on the page.</summary>
		event EventHandler<ChangeTargetUrlEventArgs^>^ ChangeTargetUrl;

		/// <summary>This event is fired when a tooltip has changed state.</summary>
		event EventHandler<ChangeTooltipEventArgs^>^ ChangeTooltip;

		/// <summary>This event is fired once the DOM (Document Object Model) for a page is ready.
		/// This is very useful for executing Javascript on a page before its content has finished loading.</summary>
		event EventHandler<DomReadyEventArgs^>^ DomReady;

		/// <summary>This event is fired when all loads have finished for a WebView.</summary>
		event EventHandler<FinishLoadingEventArgs^>^ FinishLoading;

		/// <summary>This event is fired when the contents of the page has finished loading. This 
		/// occurs at the end of most page loads.</summary>
		event EventHandler<GetPageContentsEventArgs^>^ GetPageContents;

		/// <summary>
		/// This event is fired when an external link is attempted to be opened. An external link
		/// is any link that normally opens in a new window in a standard browser (for example, links
		/// with target="_blank", calls to window.open(url), and URL open events from Flash plugins).
		/// </summary>
		event EventHandler<OpenExternalLinkEventArgs^>^ OpenExternalLink;

		/// <summary>This event is fired when the renderer for a certain plugin (usually Flash, which is
		/// isolated in a separate process) crashes unexpectedly.</summary>
		event EventHandler<PluginCrashedEventArgs^>^ PluginCrashed;

		/// <summary>This event is fired when a page title is received.</summary>
		event EventHandler<ReceiveTitleEventArgs^>^ ReceiveTitle;

		/// <summary>This event is fired once the DOM (Document Object Model) for a page is ready.
		/// This is very useful for executing Javascript on a page before its content has finished loading.</summary>
		event EventHandler<RequestDownloadEventArgs^>^ RequestDownload;

		/// <summary>This event is fired when the page requests a certain URL to be
		/// downloaded by the user.</summary>
		event EventHandler<RequestMoveEventArgs^>^ RequestMove;

		/// <summary>This event is fired when the renderer for a certain WebView (which is isolated in a
		/// separate process) crashes unexpectedly.</summary>
		event EventHandler<WebViewCrashedEventArgs^>^ WebViewCrashed;

		/// <summary>This event is fired whenever a page requests a file chooser dialog
		/// to be displayed (usually the result of an "input" element with type
		/// "file" being clicked by a user). You will need to display your own
		/// dialog (it does not have to be modal, this request does not block).
		/// Once a file has been chosen by the user, WebView.ChooseFile 
		/// (or WebView.ChooseMultipleFiles) should be called.</summary>
		event EventHandler<GetScrollDataEventArgs^>^ GetScrollData;

		/// <summary>This event is fired whenever a page requests a file chooser dialog
		/// to be displayed (usually the result of an "input" element with type
		/// "file" being clicked by a user). You will need to display your own
		/// dialog (it does not have to be modal, this request does not block).
		/// Once a file has been chosen by the user, WebView.ChooseFile 
		/// (or WebView.ChooseMultipleFiles) should be called.</summary>
		event EventHandler<RequestFileChooserEventArgs^>^ RequestFileChooser;

		/// <summary>This event is fired whenever a message is added to the Javascript
		/// console. This is usually the result of a Javascript error being
		/// encountered on a page.</summary>
		event EventHandler<JavascriptConsoleMessageEventArgs^>^ JavascriptConsoleMessage;


	internal:
		void OnBeginLoading(BeginLoadingEventArgs^ args);
		void OnBeginNavigation(BeginNavigationEventArgs^ args);
		void OnCallback(CallbackEventArgs^ args);
		void OnChangeCursor(ChangeCursorEventArgs^ args);
		void OnChangeKeyboardFocus(ChangeKeyboardFocusEventArgs^ args);
		void OnChangeTargetUrl(ChangeTargetUrlEventArgs^ args);
		void OnChangeTooltip(ChangeTooltipEventArgs^ args);
		void OnDomReady(DomReadyEventArgs^ args);
		void OnFinishLoading(FinishLoadingEventArgs^ args);
		void OnGetPageContents(GetPageContentsEventArgs^ args);
		void OnOpenExternalLink(OpenExternalLinkEventArgs^ args);
		void OnPluginCrashed(PluginCrashedEventArgs^ args);
		void OnReceiveTitle(ReceiveTitleEventArgs^ args);
		void OnRequestMove(RequestMoveEventArgs^ args);
		void OnWebViewCrashed(WebViewCrashedEventArgs^ args);
		void OnRequestDownload(RequestDownloadEventArgs^ args);
		void OnGetScrollData(GetScrollDataEventArgs^ args);
		void OnRequestFileChooser(RequestFileChooserEventArgs^ args);
		void OnJavascriptConsoleMessage(JavascriptConsoleMessageEventArgs^ args);

		WebView (WebCore^ webCore, int width, int height);

	public:
		virtual ~WebView();
	protected:
		!WebView();

	public:
		/// <summary>
		/// Whether or not the WebView has been Disposed.
		/// </summary>
		property bool IsDisposed
		{
			virtual bool get();
		}

		/// <summary>
		/// Checks whether or not there is a resize operation pending.
		/// </summary>
		/// <value>
		/// True if we are waiting for the WebView process to
		/// return acknowledgement of a pending resize operation.
		/// </value>
		property bool IsResizing
		{
			bool get();
		}

		property ResourceInterceptor^ ResourceInterceptor
		{
			AwesomiumDotNet::ResourceInterceptor^ get();
			void set(AwesomiumDotNet::ResourceInterceptor^ value);
		}

		// WebView functions

		/// <summary>
		/// Queue this WebView for destruction by the WebCore.
		/// </summary>
		void Destroy();

		/// <summary>
		/// Notifies the current page that is has gained focus. You will need
		/// to call this to gain textbox focus, among other things. (If you
		/// fail to ever see a blinking caret when typing text, this is why).
		/// </summary>
		void Focus();

		/// <summary>
		/// Notifies the current page that it has lost focus.
		/// </summary>
		void Unfocus();

		/// <summary>
		/// Invokes a 'copy' action using the system clipboard.
		/// </summary>
		void Copy();

		/// <summary>
		/// Invokes a 'cut' action using the system clipboard.
		/// </summary>
		void Cut();

		/// <summary>
		/// Invokes a 'paste' action using the system clipboard.
		/// </summary>
		void Paste();


		/// <summary>
		/// Selects all items on the current page.
		/// </summary>
		void SelectAll();

		/// <summary>
		/// Zooms the page a specified percent.
		/// </summary>
		/// <param name="zoomPercent">
		/// zoomPercent	The percent of the page to zoom to. Valid range
		/// is from 10% to 500%.
		/// </param>
		void SetZoom(int zoomPercent);

		/// <summary>
		/// Resets the zoom level.
		/// </summary>
		void ResetZoom();

		/// <summary>
		/// Resizes this WebView to certain dimensions.
		/// </summary>
		/// <param name="width">
		/// The width in pixels to resize to.
		/// </param>
		/// <param name="height">
		/// The height in pixels to resize to.
		/// </param>
		/// <param name="waitForRepaint">
		/// Whether or not to wait for the WebView to finish repainting.
		/// </param>
		/// <param name="repaintTimeoutMs">
		/// The maximum amount of time to wait for a repaint, in milliseconds.
		/// </param>
		/// <returns>
		/// Returns true if the resize was successful. This operation
		/// can fail if there is another resize already pending (see
		/// WebView.IsResizing) or if the repaint timeout was exceeded.
		/// </returns>
		bool Resize (int width, int height, bool waitForRepaint, int repaintTimeoutMs);

		/// <summary>
		/// Resizes this WebView to certain dimensions.
		/// </summary>
		/// <param name="width">
		/// The width to resize to.
		/// </param>
		/// <param name="height">
		/// The height to resize to.
		/// </param>
		/// <returns>
		/// Returns true if the resize was successful. This operation
		/// can fail if there is another resize already pending (see
		/// WebView.IsResizing) or if the repaint timeout was exceeded.
		/// </returns>
		bool Resize (int width, int height, bool waitForRepaint);

		/// <summary>
		/// Resizes this WebView to certain dimensions.
		/// </summary>
		/// <param name="width">
		/// The width to resize to.
		/// </param>
		/// <param name="height">
		/// The height to resize to.
		/// </param>
		/// <returns>
		/// Returns true if the resize was successful. This operation
		/// can fail if there is another resize already pending (see
		/// WebView.IsResizing) or if the repaint timeout was exceeded.
		/// </returns>
		bool Resize (int width, int height);

		/// <summary>
		/// Injects a mouse-move event in local coordinates.
		/// </summary>
		/// <param name="x">
		/// The absolute x-coordinate of the mouse (localized to the WebView).
		/// </param>
		/// <param name="y">
		/// The absolute y-coordinate of the mouse (localized to the WebView).
		/// </param>
		void InjectMouseMove (int x, int y);

		/// <summary>
		/// Injects a mouse-move event in local coordinates.
		/// </summary>
		/// <param name="position">
		/// The absolute coordinates of the mouse (localized to the WebView).
		/// </param>
		void InjectMouseMove (Point position);

		/// <summary>
		/// Injects a mouse-down event.
		/// </summary>
		/// <param name="button">
		/// The button that was pressed.
		/// </param>
		void InjectMouseDown (MouseButton button);

		/// <summary>
		/// Injects a mouse-down event.
		/// </summary>
		/// <param name="button">
		/// The button that was pressed.
		/// </param>
		void InjectMouseDown (MouseButtons button);

		/// <summary>
		/// Injects a mouse-up event.
		/// </summary>
		/// <param name="button">
		/// The button that was released.
		/// </param>
		void InjectMouseUp (MouseButton button);

		/// <summary>
		/// Injects a mouse-up event.
		/// </summary>
		/// <param name="button">
		/// The button that was released.
		/// </param>
		void InjectMouseUp (MouseButtons button);

		/// <summary>
		/// Injects a mouse-wheel event.
		/// </summary>
		/// <param name="scrollAmountVert">
		/// The relative amount of pixels to scroll vertically.
		/// </param>
		/// <param name="scrollAmountHorz">
		/// The relative amount of pixels to scroll horizontally.
		/// </param>
		void InjectMouseWheel (int scrollAmountVert, int scrollAmountHorz);

		/// <summary>
		/// Injects a mouse-wheel event.
		/// </summary>
		/// <param name="scrollAmountVert">
		/// The relative amount of pixels to scroll vertically.
		/// </param>
		void InjectMouseWheel (int scrollAmountVert);

		/// <summary>
		/// Injects a keyboard event.
		/// </summary>
		/// <param name="keyboardEvent">
		/// The keyboard event to inject.
		/// </param>
		void InjectKeyboardEvent (AwesomiumDotNet::WebKeyboardEvent^ keyboardEvent);

		/// <summary>
		/// Injects a keyboard event.
		/// </summary>
		void InjectKeyboardEvent (Message message);

		/// <summary>
		/// Loads a URL into the WebView asynchronously.
		/// </summary>
		/// <param name="url">
		/// The URL to load.
		/// </param>
		void LoadUrl (Uri^ url);

		/// <summary>
		/// Loads a URL into the WebView asynchronously.
		/// </summary>
		/// <param name="url">
		/// The URL to load.
		/// </param>
		void LoadUrl (String^ url);

		/// <summary>
		/// Loads a URL into the WebView asynchronously.
		/// </summary>
		/// <param name="url">
		/// The URL to load.
		/// </param>
		/// <param name="frameName">
		/// The name of the frame to load the URL in; leave this blank to load in the main frame.
		/// </param>
		void LoadUrl (Uri^ url, String^ frameName);

		/// <summary>
		/// Loads a URL into the WebView asynchronously.
		/// </summary>
		/// <param name="url">
		/// The URL to load.
		/// </param>
		/// <param name="frameName">
		/// The name of the frame to load the URL in; leave this blank to load in the main frame.
		/// </param>
		void LoadUrl (String^ url, String^ frameName);

		/// <summary>
		/// Loads a URL into the WebView asynchronously.
		/// </summary>
		/// <param name="url">
		/// The URL to load.
		/// </param>
		/// <param name="frameName">
		/// The name of the frame to load the URL in; leave this blank to load in the main frame.
		/// </param>
		/// <param name="username">
		/// If the URL requires authentication, the username to authorize as.
		/// </param>
		/// <param name="password">
		/// If the URL requires authentication, the password to use.
		/// </param>
		void LoadUrl (Uri^ url, String^ frameName, String^ username, String^ password);

		/// <summary>
		/// Loads a URL into the WebView asynchronously.
		/// </summary>
		/// <param name="url">
		/// The URL to load.
		/// </param>
		/// <param name="frameName">
		/// The name of the frame to load the URL in; leave this blank to load in the main frame.
		/// </param>
		/// <param name="username">
		/// If the URL requires authentication, the username to authorize as.
		/// </param>
		/// <param name="password">
		/// If the URL requires authentication, the password to use.
		/// </param>
		void LoadUrl (String^ url, String^ frameName, String^ username, String^ password);

		/// <summary>
		/// Loads a string of HTML into the WebView asynchronously.
		/// </summary>
		/// <param name="html">
		/// The HTML string to load.
		/// </param>
		/// <remark>
		/// The base directory (specified via WebCore.BaseDirectory)
		/// will be used to resolve relative URL's resources (such as images, links, etc).
		/// </remark>
		void LoadHtml (String^ html);

		/// <summary>
		/// Loads a string of HTML into the WebView asynchronously.
		/// </summary>
		/// <param name="html">
		/// The HTML string to load.
		/// </param>
		/// <param name="frameName">
		/// The name of the frame to load the HTML in; leave this blank to load in the main frame.
		/// </param>
		/// <remark>
		/// The base directory (specified via WebCore.BaseDirectory)
		/// will be used to resolve relative URL's resources (such as images, links, etc).
		/// </remark>
		void LoadHtml (String^ html, String^ frameName);

		/// <summary>
		/// Loads a local file into the WebView asynchronously.
		/// </summary>
		/// <param name="file">
		/// The file to load.
		/// </param>
		/// <remark>
		/// The file should exist within the base directory
		/// (specified via WebCore.BaseDirectory).
		/// </remark>
		void LoadFile (String^ file);

		/// <summary>
		/// Loads a local file into the WebView asynchronously.
		/// </summary>
		/// <param name="file">
		/// The file to load.
		/// </param>
		/// <param name="frameName">
		/// The name of the frame to load the file in; leave this blank to load in the main frame.
		/// </param>
		void LoadFile (String^ file, String^ frameName);

		/// <summary>
		/// Sets whether or not pages should be rendered with transparency
		/// preserved. (ex, for pages with style="background-color:transparent")
		/// </summary>
		/// <param name="isTransparent">
		/// Whether or not this WebView is transparent.
		/// </param>
		void SetTransparent (bool isTransparent);

		/// <summary>
		/// Renders this WebView into an offscreen render buffer and clears the dirty state.
		/// </summary>
		/// <returns>
		/// A pointer to the internal render buffer that was used to render this WebView.
		/// This value may change between renders and may return null if the WebView has crashed.
		/// </returns>
		AwesomiumDotNet::RenderBuffer^ Render ();

		/// <summary>
		/// All rendering is actually done asynchronously in a separate process
		/// and so the page is usually continuously rendering even if you never 
		/// call WebView.Render. Call this to temporarily pause rendering.
		/// </summary>
		void PauseRendering();

		/// <summary>
		/// Resume rendering after all call to WebView.PauseRendering.
		/// </summary>
		void ResumeRendering();

		/// <summary>
		/// Returns whether or not the current web-view is dirty and needs to be re-rendered.
		/// </summary>
		/// <returns>
		/// If the web-view is dirty, returns true, otherwise returns false.
		/// </returns>
		property bool IsDirty
		{
			bool get();
		}

		/// <summary>
		/// Returns whether or not a page is currently loading in the WebView.
		/// </summary>
		/// <returns>
		/// If a page is loading, returns true, otherwise returns false.
		/// </returns>
		property bool IsLoadingPage
		{
			bool get();
		}

		/// <summary>
		/// Returns the bounds of the area that has changed since the last call to WebView::render.
		/// </summary>
		/// <returns>
		/// The bounds of the dirty area.
		/// </returns>
		property System::Drawing::Rectangle^ DirtyBounds
		{
			System::Drawing::Rectangle^ get();
		}

		/// <summary>
		/// Navigates back/forward in history via a relative offset.
		/// </summary>
		/// <param name="offset">
		/// The relative offset in history to navigate to.
		/// </param>
		/// <remarks>
		/// For example, to go back one page:
		///   myView.GoToHistoryOffset(-1);
		/// Or, to go forward one page:
		///   myView.GoToHistoryOffset(1);
		/// </remarks>
		void GoToHistoryOffset(int offset);

		/// <summary>
		/// Stops the current navigation.
		/// </summary>
		void Stop();

		/// <summary>
		/// Reloads the current page.
		/// </summary>
		void Reload();

		/// <summary>
		/// Executes a string of JavaScript in the context of the current page asynchronously.
		/// </summary>
		/// <param name="javaScript">
		/// The string of JavaScript to execute.
		/// </param>
		void ExecuteJavaScript (String^ javaScript);

		/// <summary>
		/// Executes a string of JavaScript in the context of the current page asynchronously.
		/// </summary>
		/// <param name="javaScript">
		/// The string of JavaScript to execute.
		/// </param>
		/// <param name="frameName">
		/// The name of the frame to execute in; leave this blank to execute in the main frame.
		/// </param>
		void ExecuteJavaScript (String^ javaScript, String^ frameName);

		/// <summary>
		/// Executes a string of JavaScript in the context of the current page asynchronously with a result.
		/// </summary>
		/// <param name="javaScript">
		/// The string of JavaScript to execute.
		/// </param>
		/// <returns>
		/// Returns a 'FutureJSValue' which is basically an 'IOU' for the future JSValue result.
		/// You can obtain the actual result via FutureJSValue.Get later.
		/// </returns>
		FutureJSValue^ ExecuteJavaScriptWithResult (String^ javaScript);

		/// <summary>
		/// Executes a string of JavaScript in the context of the current page asynchronously with a result.
		/// </summary>
		/// <param name="javaScript">
		/// The string of JavaScript to execute.
		/// </param>
		/// <param name="frameName">
		/// The name of the frame to execute in; leave this blank to execute in the main frame.
		/// </param>
		/// <returns>
		/// Returns a 'FutureJSValue' which is basically an 'IOU' for the future JSValue result.
		/// You can obtain the actual result via FutureJSValue.Get later.
		/// </returns>
		FutureJSValue^ ExecuteJavaScriptWithResult (String^ javaScript, String^ frameName);

		/// <summary>
		/// Creates a new global JavaScript object that will persist throughout the lifetime of this WebView.
		/// This object is managed directly by Awesomium and so you can modify its properties and bind
		/// callback functions via WebView.SetObjectProperty and WebView.SetObjectCallback, respectively.
		/// </summary>
		/// <param name="objectName">
		/// The name of the object.
		/// </param>
		void CreateObject (String^ objectName);

		/// <summary>
		/// Destroys a JavaScript object previously created by WebView.CreateObject.
		/// </summary>
		/// <param name="objectName">
		/// The name of the object to destroy.
		/// </param>
		void DestroyObject (String^ objectName);

		/// <summary>
		/// Call a certain function defined in JavaScript directly.
		/// </summary>
		/// <param name="objectName">
		/// The name of the object that contains the function, pass an empty string if the function
		/// is defined in the global scope.
		/// </param>
		/// <param name="functionName">
		/// The name of the function.
		/// </param>
		/// <param name="args">
		/// The arguments to pass to the function.
		/// </param>
		void CallJavaScriptFunction (String^ objectName, String^ functionName, IEnumerable<JSValue^>^ args);

		/// <summary>
		/// Call a certain function defined in JavaScript directly.
		/// </summary>
		/// <param name="objectName">
		/// The name of the object that contains the function, pass an empty string if the function
		/// is defined in the global scope.
		/// </param>
		/// <param name="functionName">
		/// The name of the function.
		/// </param>
		/// <param name="args">
		/// The arguments to pass to the function.
		/// </param>
		/// <param name="frameName">
		/// Optional, the name of the frame to execute in; leave this blank to execute in the main frame.
		/// </param>
		void CallJavaScriptFunction (String^ objectName, String^ functionName, IEnumerable<JSValue^>^ args, String^ frameName);

		/// <summary>
		/// Sets a property of a JavaScript object previously created by WebView.CreateObject.
		/// </summary>
		/// <param name="objectName">
		/// The name of the JavaScript object.
		/// </param>
		/// <param name="propName">
		/// The name of the property.
		/// </param>
		/// <param name="value">
		/// The javascript-value of the property.
		/// </param>
		void SetObjectProperty(String^ objectName, String^ propName, JSValue^ value);

		/// <summary>
		/// Sets a callback function of a JavaScript object previously created by WebView.CreateObject.
		/// This is very useful for passing events from JavaScript. To receive notification of the callback,
		/// an OnCallback event handler should be registered (see WebView.OnCallback).
		/// </summary>
		/// <param name="objectName">
		/// The name of the JavaScript object.
		/// </param>
		/// <param name="callbackName">
		/// The name of the callback function.
		/// </param>
		void SetObjectCallback (String^ objectName, String^ callbackName);

		/// <summary>
		/// Sets the current URL Filtering Mode (default is None).
		/// See UrlFilteringMode for more information on the modes.
		/// </summary>
		/// <param name="mode">
		/// The URL filtering mode to use.
		/// </param>
		void SetUrlFilteringMode (UrlFilteringMode mode);

		/// <summary>
		/// Adds a new URL Filter rule.
		/// </summary>
		/// <param name="filter">
		/// A string with optional wildcards that describes a certain URL.
		/// </param>
		/// <remarks>
		/// For example, to match all URLs from the domain "google.com", your filter string 
		/// might be: http://google.com/*
		/// You may also use the "local://" scheme prefix to describe the URL to the base
		/// directory (set via WebCore.BaseDirectory).
		/// </remarks>
		void AddUrlFilter (String^ filter);

		/// <summary>
		/// Clears all URL Filter rules.
		/// </summary>
		void ClearAllUrlFilters();

		/// <summary>
		/// Defines a new Header Definition or updates it if it already exists.
		/// </summary>
		/// <param name="name">
		/// The unique name of the Header Definition; this is used to refer to it later 
		/// in WebView.AddHeaderRewriteRule and WebView.RemoveHeaderRewriteRulesByDefinitionName.
		/// </param>
		/// <param name="definition">
		/// The header definition, a map of key/values representing an HTTP header.
		/// </param>
		void SetHeaderDefinition (String^ name, IDictionary<String^, String^>^ definition);

		/// <summary>
		/// Adds a new a header re-write rule. All requests whose URL matches the specified rule will have its 
		/// HTTP headers re-written with the specified header definition before sending it to the server.
		/// </summary>
		/// <param name="rule">
		/// A wide string with optional wildcards (*, ?) that matches the URL(s) that will
		/// have its headers re-written with the specified header definition.
		/// </param>
		/// <param name="name">
		/// The name of the header definition (specified in WebView.SetHeaderDefinition).
		/// </param>
		/// <remarks>
		/// The case where a URL is matched by multiple rules is unsupported, only the first match will be used.
		/// </remarks>
		void AddHeaderRewriteRule (String^ rule, String^ name);

		/// <summary>
		/// Removes a header re-write rule from this WebView.
		/// </summary>
		/// <param name="rule">
		/// The rule to remove (should match the string specified in WebView.AddHeaderRewriteRule exactly).
		/// </param>
		void RemoveHeaderRewriteRule (String^ rule);

		/// <summary>
		/// Removes all header re-write rules that are using a certain header definition.
		/// </summary>
		/// <param name="name">
		/// The name of the header definition (specified in WebView.SetHeaderDefinition). If you
		/// specify an empty string, this will remove ALL header re-write rules.
		/// </param>
		void RemoveHeaderRewriteRulesByDefinitionName (String^ name);

		/// <summary>
		/// This should be called as a response to WebViewListener::onRequestFileChooser.
		/// </summary>
		/// <param name="filePath">
		/// The full path to the file that was chosen.
		/// </param>
		void ChooseFile (String^ filePath);

		/// <summary>
		/// This should be called as a response to WebViewListener.OnRequestFileChooser
		/// when multiple files have been selected.
		/// </summary>
		/// <param name="filePaths">
		/// The full paths to all the files that were chosen.
		/// </param>
		void ChooseMultipleFiles (IEnumerable<String^>^ filePaths);

		/// <summary>
		/// Print the current page. To suppress the printer selection dialog and
		/// print immediately using the operating system's defaults, see 
		/// WebCore.SetSuppressPrinterDialog.
		/// </summary>
		void Print();

		/// <summary>
		/// Request the page dimensions and scroll position of the page. You can
		/// retrieve the response via WebViewListener.OnGetScrollData.
		/// </summary>
		/// <param name="frameName">
		/// The frame's scroll data to retrieve. Leave blank
		/// to get the main frame's scroll data.
		/// </param>
		void RequestScrollData (String^ frameName);

		/// <summary>
		/// Request the page dimensions and scroll position of the page. You can
		/// retrieve the response via WebViewListener.OnGetScrollData.
		/// </summary>
		void RequestScrollData ();
	};
}
